//
//  UILabel+ZLCategory.m
//  ZLCategory
//
//  Created by zhaozl on 2022/4/30.
//

#import "UILabel+ZLCategory.h"

@implementation UILabel (ZLCategory)

- (void)zl_setLineSpacing:(CGFloat)space {
    if (self.text && self.text.length > 0) {
        NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:self.text];
        NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
        [paragraphStyle setLineSpacing:space];
        [attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [self.text length])];
        self.attributedText = attributedString;
        self.lineBreakMode = NSLineBreakByTruncatingTail;
    }
}

@end
